tools/babl-verify: print selected fast path if a third argument is provided
authorØyvind Kolås <pippin@gimp.org>
Thu, 15 Dec 2016 15:40:02 +0000 (16:40 +0100)
committerØyvind Kolås <pippin@gimp.org>
Thu, 15 Dec 2016 15:40:02 +0000 (16:40 +0100)
tools/babl-verify.c

index 80174db50e88c759a55c37f624e5756abda2313f..83b1620f4ac2d81e84cce74b6f650a84eb97681e 100644 (file)
@@ -1,18 +1,44 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include "babl/babl.h"
+#include "../config.h"
+#include "babl/babl-internal.h"
 
 int main (int argc, char **argv)
 {
-  if (argc != 3)
+  int final = 0;
+  const Babl *fish;
+  if (argc < 3)
   {
     fprintf (stderr, "need two args, from and to babl-formats\n");
     return -1;
   }
+  if (argc == 4)
+    final = 1;
+
+  if (!final)
+  {
   putenv ("BABL_DEBUG_CONVERSIONS" "=" "1");
   putenv ("BABL_TOLERANCE"         "=" "100000.0");
+  }
+
   babl_init ();
-  babl_fish (babl_format(argv[1]), babl_format (argv[2]));
+
+  fish = babl_fish (babl_format(argv[1]), babl_format (argv[2]));
+  if (!fish)
+    return -1;
+
+  if (final)
+  switch (fish->class_type)
+  {
+    case BABL_FISH:
+      fprintf (stderr, "%s\n", babl_get_name (fish));
+            break;
+    case BABL_FISH_PATH:
+      fprintf (stderr, "chosen %s to %s: steps: %i error: %f cost: %f\n", argv[1], argv[2], fish->fish_path.conversion_list->count, fish->fish.error, fish->fish_path.cost);
+            break;
+  }
+
+
   babl_exit ();
 
   return 0;